package TrueTopic;

import java.util.Scanner;

public class TestJ {
    static int cnt = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            int q = sc.nextInt();
            for (int i = 0; i < q; i++) {
                int opi = sc.nextInt();
                int xi = sc.nextInt();
                sc.nextLine();
                if (opi == 1) {
                    add(n, xi);
                    System.out.println(cnt);
                }
                if (opi == 2) {
                    ask(n, xi);
                    System.out.println(cnt);
                }
                cnt = 0;
            }
        }
    }


    public static void add(int x, int n) {
        for (int k = 0; k <= n; k++) {
            for (int i = x + k; i <= n + k; i++) {
                cnt++;
            }
        }
    }

    public static void ask(int x, int n) {
        for (int k = 0; k <= n; k++) {
            for (int i = x + k; i != 0; i -= i & -i) {
                cnt++;
            }
        }
    }

}
